<?php
class Faqs extends Admin_Controller
{
	
	function __construct()
	{
		parent::__construct();
	}
	
	function index()
	{
		$data['faqs'] = new faq;
		$data['faqs']->order_by('id','desc')->get_page();
		$this->template->append_metadata(js_checkbox('approve'));
		$this->template->build('admin/faq_index',$data);
	}
	
	function form($id=NULL)
	{

		$data['faq'] = new faq($id);
		$this->template->build('admin/faq_form',$data);
	}
	
	function save($id=NULL)
	{
		if($_POST)
		{
			$faq = new faq($id);
			$faq->user_id = $this->session->userdata('id');
			$faq->from_array($_POST);
			$faq->save();
			set_notify('success', lang('save_data_complete'));
		}
		redirect('faqs/admin/faqs');
	}
	
	function approve($id)
	{
		if($_POST)
		{
			$faq = new faq($id);
			$faq->from_array($_POST);
			$faq->save();
		}

	}
	
	function delete($id)
	{
		if($id)
		{
			$faq = new faq($id);
			$faq->delete();
			set_notify('success', lang('delete_data_complete'));
		}
		redirect($_SERVER['HTTP_REFERER']);
	}

}
?>